﻿<%@ Page Language="VB"  AutoEventWireup="false"
    CodeFile="ManageOrganization.aspx.vb" Inherits="WebForm_ManageOrganization" EnableEventValidation="false" %>


<%@ Register Src="~/WebForm/Manage/ManageOrganization/AddOrganization.ascx" TagName="AddOrganization"
    TagPrefix="My" %>
<%@ Register Assembly="App_Code" Namespace="My" TagPrefix="My" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>  
<script type="text/javascript">
    function crtCSS(cssName) {
        var headID = document.getElementsByTagName("head")[0];
        var newCss = document.createElement('link');
        newCss.type = 'text/css';
        newCss.rel = "stylesheet";
        newCss.href = cssName;
        headID.appendChild(newCss);
    }
</script>
</head>
    <script type="text/javascript">
// xtreeView JScript File



var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

var menuobj = null
//if (ie5||ns6)
//var menuobj=document.getElementById("Panel2")
function showmenuie5(e,newobjID){

if (newobjID != null)
{	
    menuobj=document.getElementById(newobjID)
}


//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
else
menuobj.style.top=ie5? document.documentElement.scrollTop+event.clientY : window.pageYOffset+e.clientY

if(ie5)
    window.event.cancelBubble = true;
else if(ns6)
    e.stopPropagation();

menuobj.style.visibility="visible"

    
return false
}



function hidemenuie5(e){
menuobj.style.visibility="hidden"
}

function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") 
firingobj=firingobj.parentNode //up one node

firingobj.style.backgroundColor="highlight"

}
}

function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") 
firingobj=firingobj.parentNode //up one node

firingobj.style.backgroundColor=""


window.status=''
}
}

function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems") 
var firingobj2=firingobj.parentNode
// the click can be controlled by firingobj
// if the click was generated by the div tag enclosing the link buttons
//then the value of firingobj=htmlDivElement el
// else if the click was generated by the linkbutton
// then the value of firingobj will be href of the link button and the value of firingobj2 will be htmlDivElement
// the code for controlling the clciks goes here

}

}

if (ie5||ns6){
//menuobj.style.display=''
document.onclick=function(e) {

        if (menuobj != null)
        {
            hidemenuie5(e)
        }
    }

    //document.onclick = hidemenuie5
}

</script>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" background-repeat="repeat">
    <form id="form1" runat="server">
     <asp:ScriptManager ID="smBase" runat="server">
    </asp:ScriptManager>
    <table align="center" width="95%">
        <tr>
            <td align="center">
                <asp:Label ID="Title" runat="server" SkinID="title" meta:resourcekey="Page"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" AutoPostBack="false"
                    ActiveTabIndex="0">
                    <ajaxToolkit:TabPanel ID="SearchTabPanel" runat="server" meta:resourcekey="SearchTabPanel">
                        <ContentTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <fieldset>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lblActive" runat="server" meta:resourceKey="lblActive"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:DropDownList ID="ddlActive" runat="server" AutoPostBack="True">
                                                            <asp:ListItem meta:resourceKey="ActiveY"></asp:ListItem>
                                                            <asp:ListItem meta:resourceKey="ActiveN"></asp:ListItem>
                                                        </asp:DropDownList>
                                                    </td>
                                                    <td>
                                                        <asp:Button ID="btnQuery" runat="server" CommandName="btnQuery" 
                                                            meta:resourceKey="btnQuery" Visible="False" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                 <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
                                            <ContentTemplate>
                                                <asp:TreeView ID="trOrganization" runat="server" ImageSet="Simple" ShowLines="true"
                                                    CssClass="tree">
                                                    <Nodes>
                                                        <My:MyTreeNode MyText="Root">
                                                            <%--<My:MyTreeNode Text="<span oncontextmenu='return showmenuie5(event)'>組織1</span>">--%>
                                                            <My:MyTreeNode MyText="組織1">
                                                                <My:MyTreeNode MyText="組織3">
                                                                </My:MyTreeNode>
                                                            </My:MyTreeNode>
                                                            <My:MyTreeNode MyText="組織2">
                                                            </My:MyTreeNode>
                                                        </My:MyTreeNode>
                                                    </Nodes>
                                                    <NodeStyle Font-Size="9pt" />
                                                </asp:TreeView>
                                          </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <asp:Panel ID="Panel2" runat="server" BorderColor="Black" CssClass="skin0"  onClick="jumptoie5(event)">
                
                                            <asp:Menu ID="ContextMenu1" runat="server" Font-Size="9pt" Width="100%">
                                                <StaticItemTemplate>
                                                    <asp:Label ID="lblMenuItem" runat="server" Text='<%# Eval("Text") %>' onclick="if(this.innerText=='停用') return confirm('確定停用?');"></asp:Label>
                                                </StaticItemTemplate>
                                                <Items>
                                                    <asp:MenuItem Value="Add" meta:resourcekey="miAdd" Text="Add"></asp:MenuItem>
                                                    <asp:MenuItem Value="Edit" meta:resourcekey="miEdit" Text="Edit"></asp:MenuItem>
                                                    <asp:MenuItem Value="Disable" meta:resourcekey="miDisable" Text="Disable"></asp:MenuItem>
                                                    <asp:MenuItem Value="Cut" meta:resourcekey="miCut" Text="Cut"></asp:MenuItem>
                                                    <asp:MenuItem Value="Paste" meta:resourcekey="miPaste" Text="Paste"></asp:MenuItem>
                                                </Items>
                                                <StaticHoverStyle BackColor="#9999FF" />
                                            </asp:Menu>
                                        </asp:Panel>
                                    </td>
                                </tr>
                            </table>
                        </ContentTemplate>
                    </ajaxToolkit:TabPanel>
                    <ajaxToolkit:TabPanel ID="AddTabPanel" runat="server" meta:resourcekey="AddTabPanel">
                        <ContentTemplate>
                            <My:AddOrganization ID="AddOrganization1" runat="server" />
                        </ContentTemplate>
                    </ajaxToolkit:TabPanel>
                </ajaxToolkit:TabContainer>
            </td>
        </tr>
    </table>
    <br />

    <script>


  
if (ie5||ns6)  
  menuobj=document.getElementById("<%= Me.Panel2.ClientID %>")  ;
  
  //alert(document.onclick);
    </script>


 </form>
</body>



</html>
